package com.luban.service;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
import org.springframework.stereotype.Component;

@Component
public class TestBeanPostProcessor implements BeanPostProcessor, InstantiationAwareBeanPostProcessor {

	@Override
	//实例化前
	public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
		System.out.println("实例化前 -- postProcessBeforeInstantiation : "+beanName);
		return null;
	}

	@Override
	//实例化后
	public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException {
		System.out.println("实例化后 -- postProcessAfterInstantiation : "+beanName);
		return false;
	}

	@Override
	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
		System.out.println("初始化前。。。postProcessBeforeInitialization : "+beanName);
//		return null;
		return bean;
	}

	@Override
	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
		System.out.println("初始化后。。。postProcessAfterInitialization : "+beanName);
		return null;
//		return bean;
	}
}
